export default {
  bind(el, binding, vnode) {
    var middleValue = 0
    // var middleTime = 1500
    var num = parseInt(binding.value)
    // console.log(num)
    if (!isNaN(binding.value)) {
      middleValue = parseInt(num) - 15
    }
    const value = middleValue > 0 ? middleValue : 0
    el.innerHTML = value
    /* if (value === 0) {
      middleTime = num * 100
    } */
    if (num !== 0) {
      var interval = setInterval(function() {
        el.innerHTML = parseInt(el.innerHTML) + 1
        // console.log(parseInt(el.innerHTML))
        if (parseInt(num) == parseInt(el.innerHTML)) { // eslint-disable-line
          clearInterval(interval)
        }
      }, 100)
    }
    /* setTimeout(function() {
      clearInterval(interval)
    }, middleTime) */
  }
}
